from datetime import datetime

from sqlalchemy import Column, Integer, String, DateTime
from sqlalchemy.dialects import postgresql

from config.database import Base


class SysUserModel(Base):
    """
    系统用户实体
    """
    __tablename__ = 'tb_sys_user'
    __table_args__ = {
        'schema': 'backend'
    }

    user_id = Column(Integer, primary_key=True, autoincrement=True, comment='表主键索引')
    user_name = Column(String(20), comment='用户真实名称')
    user_desc = Column(String(100), comment='用户简介')
    user_avatar = Column(String(255), comment='用户头像')
    login_name = Column(String(20), nullable=False, comment='登录账号')
    login_password = Column(String(50), nullable=False, comment='登录密码')
    look_dept_permissions = Column(postgresql.ARRAY(Integer), comment='可查看点评的权限')
    create_time = Column(DateTime, default=datetime.now(), comment='创建时间')
    last_login_time = Column(DateTime, default=datetime.now(), comment='最后一次登录时间')
